/*
 * Copyright (C) 2014 Nathan Templon
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package function;

/**
 *
 * @author Nathan Templon
 */
public interface Function {
    
    Variable[] getVariables();
    double getValue();
    
    public class Variable {
        
        public Variable(String name) {
            this.name = name;
        }
        
        public void setValue(double d) {
            this.value = d;
        }
        
        public double getValue() {
            return this.value;
        }
        
        public String getName() {
        	return name;
        }
        
        private String name;
        private double value;
    }
    
    
    public class FuncPoint implements Comparable<Object> {
        
        public FuncPoint(double x, double y) {
            this.x = x;
            this.y = y;
        }
        
        public double x() {
            return x;
        }
        
        public double y() {
            return y;
        }
        
        private double x;
        private double y;

        @Override
        public int compareTo(Object o) {
            if (!(o instanceof FuncPoint)) {
                return 0;
            }
            FuncPoint other = (FuncPoint)o;
            return Double.compare(this.x(), other.x());
        }
    }
    
    
    public class Domain {
        public Domain(double minVal, double maxVal) {
            this.min = minVal;
            this.max = maxVal;
        }
        
        public double min() {
            return min;
        }
        
        public double max() {
            return max;
        }
        
        public boolean inDomain(double d) {
            return (d >= min && d <= max);
        }
        
        private double min;
        private double max;
    }
    
    
    public class Range {
        public Range(double minVal, double maxVal) {
            this.min = minVal;
            this.max = maxVal;
        }
        
        public double min() {
            return min;
        }
        
        public double max() {
            return max;
        }
        
        public boolean inDomain(double d) {
            return (d >= min && d <= max);
        }
        
        private double min;
        private double max;
    }
    
}
